home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / bbsutil / hsrc_117.zip / NOTEPAD.C < prev    next >
Text File  |  1990-11-08  |  2KB  |  79 lines

  1. /* Notepad.C File */
  2.  
  3. #include <alloc.h>
  4. #include <conio.h>
  5. #include <stdio.h>
  6. #include <mem.h>
  7. #include <string.h>
  8. #include <process.h>
  9. #include <io.h>
  10. #include <fcntl.h>
  11. #include "twindow.h"
  12.  
  13. char LWID;
  14. char WHT;
  15. int PADHT;
  16.  
  17. extern unsigned int maxx,maxy;
  18. extern char notefile[];
  19. extern char abortedit;
  20.  
  21. char *bf;
  22.  
  23.  
  24. extern char * pascal rstrip(char *);
  25. extern char * pascal fgetsx(char *,int,int);
  26. extern void pascal save_text(int justblk,int append);
  27. extern void pascal get_rid(void);
  28.  
  29. void pascal notepad(void);
  30.  
  31.  
  32.  
  33. void pascal notepad (void) {
  34.  
  35.   WINDOW *wnd;
  36.   char *endtext;
  37.   int wasx,wasy;
  38.  
  39.   WHT=maxy-7;
  40.   LWID=maxx-2;
  41.   PADHT=32766/LWID;
  42.  
  43.   curr_cursor(&wasx,&wasy);
  44.  
  45.   bf=(char *)malloc((unsigned int)((PADHT * LWID)+1));
  46.   if(!bf) {
  47.         printf("\nOut of memory\n");
  48.         get_rid();
  49.         return;
  50.   }
  51.  
  52.   set_help("edithelp  ",0,0);
  53.   wnd=establish_window((maxx-(LWID+2))/2,(maxy-(WHT+2)),WHT+2,LWID+2);
  54.   set_border(wnd,3);
  55.   set_title(wnd," Mini Text Editor ");
  56.   set_colors(wnd,ALL,BLACK,WHITE,BRIGHT);
  57.   set_colors(wnd,ACCENT,WHITE,BLACK,DIM);
  58.   set_colors(wnd,ACCENT,WHITE,BLUE,DIM);
  59.   set_colors(wnd,BORDER,BLACK,BLUE,BRIGHT);
  60.   set_colors(wnd,TITLE,BLACK,AQUA,BRIGHT);
  61.   display_window(wnd);
  62.  
  63.   endtext=text_editor(wnd,bf,(unsigned)LWID*PADHT);
  64.  
  65.   if (abortedit) {               /* Just quit */
  66.      if(!stricmp(notefile,"MSGTMP")) unlink(notefile);
  67.      any_message(" Aborted ");
  68.   }
  69.   else {
  70.     if(endtext!=bf) {
  71.         save_text(0,0);
  72.     }
  73.   }
  74.   free(bf);
  75.   clear_message();
  76.   delete_window(wnd);
  77.   cursor(wasx,wasy);
  78. }
  79.